<%@ page pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<jsp:include page="common/header.jsp"></jsp:include>
<script type="text/javascript" src="${pageContext.request.contextPath}/views/js/utils.js"></script>


<h1><img src="${pageContext.request.contextPath}/views/images/icons/posts.png" alt="" />订单详情</h1>
<a id="button_add" class="mypage_button"  onClick="javascript :history.go(-1);"><img src="${pageContext.request.contextPath}/views/images/icons/menu/dark/chart.png"/>返回</a>
<%-- <a  class="mypage_button" style="margin-top:-0.5;margin-right:20px;" href="javascript:batchPush();">
<img src="${pageContext.request.contextPath}/views/images/icons/menu/dark/chart.png"/>批量推送</a> --%>
<div class="bloc">
    <div class="title">
               订单基本信息
    </div>
    <div  class="input">
                &nbsp;&nbsp;&nbsp; 订单金额总计：<fmt:formatNumber type="number" value="${order.payCash}" pattern="0.00" maxFractionDigits="2"/>元（运费<fmt:formatNumber type="number" value="${order.payExpress }" pattern="0.00" maxFractionDigits="2"/>元，已优惠<fmt:formatNumber type="number" value="${order.payDiscount}" pattern="0.00" maxFractionDigits="2"/>元）<br/>
                &nbsp;&nbsp;&nbsp; 订单编号 ：${order.orderNum }<br/>             
                &nbsp;&nbsp;&nbsp; 下单时间 ：<fmt:formatDate value="${order.ctime}" type="both"/><br/>
                &nbsp;&nbsp;&nbsp; 订单状态： <c:if test="${order.status==0}">已删除</c:if>
                                             <c:if test="${order.status==1}">已取消</c:if>
                                             <c:if test="${order.status==2}">已过期</c:if>
                                             <c:if test="${order.status==10}">正常单</c:if>
                                             <c:if test="${order.status==99}">已完成</c:if>  <br/>
                &nbsp;&nbsp;&nbsp; 支付状态 ：<c:if test="${order.payStatus ==0}">未付款</c:if>
                                             <c:if test="${order.payStatus ==1}">已付款</c:if>
                                             <c:if test="${order.payStatus ==10}">已退款</c:if><br/>  
                &nbsp;&nbsp;&nbsp; 支付方式 ：<c:if test="${order.payType==0}">微信支付</c:if>
                                             <c:if test="${order.payType==1}">快捷支付</c:if> <br/>
                <c:if test="${order.payStatus >1}">                              
                &nbsp;&nbsp;&nbsp; 支付时间 ：<fmt:formatDate value="${order.payTime }" type="both"/><br/>  
                </c:if>    
                <c:if test="${order.payStatus == 10}">                               
                &nbsp;&nbsp;&nbsp; 退款时间 ：<fmt:formatDate value="${order.refundTime }" type="both"/><br/>  
                </c:if>    
    </div>
    <div class="title">
           用户基本信息
    </div>
    <div class="input">
     &nbsp;&nbsp;&nbsp; 用户昵称：${user.wxNickName }  &nbsp;&nbsp;&nbsp; 性别： <c:if test="${user.wxSex==0}">女</c:if><c:if test="${user.wxSex==1}">男</c:if>  &nbsp;&nbsp;&nbsp; 
    </div>
	 <br/>
    <div class="title">
          配送信息：
    </div>
    <div class="input">
         &nbsp;&nbsp;&nbsp;配送状态：<c:if test="${order.expressStatus==0}">未发货</c:if><c:if test="${order.expressStatus==1}">已发货</c:if><c:if test="${order.expressStatus==10}">已签收</c:if>        <br/>    
         <c:if test="${order.expressStatus>0}">
         &nbsp;&nbsp;&nbsp;配送方式：${order.expressCompanyName }        <br/>  
         &nbsp;&nbsp;&nbsp;配送单号：${order.expressNo }        <br/>    
         </c:if>  
         &nbsp;&nbsp;&nbsp;收件人：${order.receiverName }             <br/>    
         &nbsp;&nbsp;&nbsp;地址：${order.receiverAddress } <br/>    
         &nbsp;&nbsp;&nbsp;联系方式：${order.receiverMobile }          <br/>    
    </div>
    <div class="title">
      商品信息（共计<font id="totalCount"> </font>条）
    </div>
	<div class="content">
        <table id="jgcsTable">
            <thead>
                <tr>
                    <th>序号</th>
					<th>id</th>
					<th>订单号</th>
					<th>主图</th>
					<th>商品名称</th>
					<th>单件价格</th>
					<th>单件优惠价</th>
					<th>整箱售价</th>
					<th>整箱折扣价</th>
					<th>购买类型</th>
					<th>购买数量</th>
					<th>评分</th>
					<th>评论</th>
					<th>评论时间</th>
                </tr>
            </thead>
            <tbody id="tb_body">
            </tbody>
        </table>
        <div class="submit" style="margin-top: 20px;">
        </div>
        <div id="kkpager">
        
        </div>
    </div>
</div>
<script type="text/javascript">
var curPageName = "admin-gftgoodsorder";
changeCurrent();
$(function(){
	BindData(1);
});

// 查询按钮事件绑定
function bindSearch(){
	$('#button_search').unbind().bind('click',function(){
		BindData();
	});
} 


//AJAX方法取得数据并显示到页面上
function BindData(pageIndex) {
	var orderNum='${order.orderNum}';
	var orderStr = "id desc";
	$.ajax({
		type : "post", // 使用get方法访问后台
		dataType : "json", // 返回json格式的数据
		url : "${pageContext.request.contextPath}/admin-gftgoodsordersku/ajaxdataList", // 要访问的后台地址
		data : {
			"orderNum":orderNum,
			"orderStr":orderStr,
			"page" : pageIndex,
			"size":20
		}, // 要发送的数据
		ajaxStart : function() {
			$("#load").show();
		},
		complete : function() {
			$("#load").hide();
		}, // AJAX请求完成时隐藏loading提示
		success : function(msg) {// msg为返回的数据，在这里做数据绑定
			var data = msg.data;//列表数据
			var curPageIndex=msg.curPage;//当前页码
			var total=msg.total;//数据总条数
			$("#totalCount").text(total);
			var totalPage=msg.totalPage;//页面总数
			$("#tb_body").empty(); // 在读取数据时如果表格已存在行．一律删除
			var tmp = "";
			var ordNo = (curPageIndex-1)*20;//序号
			$.each(data,
					function(i, item) {
						ordNo++;
						var buyType = "单件购买";
						if(item.buyType == 1){
							buyType = "整箱购买";
						}
						var commentTime = "";
						if (item.commentTime != null
								&& item.commentTime != "") {
							commentTime = new Date();
							commentTime.setTime(item.ctime);
							commentTime = commentTime.Format('yyyy-MM-dd hh:mm:ss');

						}
						$("#jgcsTable").append(
												"<tr><td style='width:5%'>" +
														+ ordNo + "</td>"
															+ "<td>" + item.id +  "</td>"
															+ "<td>" + item.orderNum +  "</td>"
															+ "<td><img src=${baseImgUrl}" + item.image +  " height='50' width='50'></td>"
															+ "<td>" + item.goodsName +  "</td>"
															+ "<td>" + item.singlePrice +  "</td>"
															+ "<td>" + item.singleDiscount +  "</td>"
															+ "<td>" + item.fullPrice +  "</td>"
															+ "<td>" + item.fullDiscount +  "</td>"
															+ "<td>" + buyType +  "</td>"
															+ "<td>" + item.buyNum +  "</td>"
															+ "<td>" + (item.grade == null ? '' : item.grade) +  "</td>"
															+ "<td>" + (item.comment == null ? '' : item.comment) +  "</td>"
															+ "<td>" + commentTime +  "</td>");
			});
			generPageBar("BindData", curPageIndex, totalPage, total);
		},
		error : function() {
			var t = document.getElementById("tb_body"); // 获取展示数据的表格
			while (t.rows.length != 0) {
				t.removeChild(t.rows[0]); // 在读取数据时如果表格已存在行．一律删除
			}
			myAlert("加载数据失败");
		} 
	});
}

function reSizePic( obj ){
	var src = obj.src;
	var divPic = document.createElement("div");
	divPic.className = 'picBox'
	divPic.innerHTML = "<span class='close'>X</span><div class='center_pic'><img src="+src+" /></div>";
	document.body.appendChild(divPic);
	var w = $('.center_pic img').width();
	var h = $('.center_pic img').height();
	$('.center_pic').css({marginLeft: - (w/2), marginTop: - (h/2)});
	$('.close').click(function(){
		$('.picBox').css({'display':'none'})
		/* divPic.remove(); */
	})
}
	</script>